package cz.proks.schoolpupilbook.gae.restlet.resource;

import cz.proks.schoolpupilbook.gae.dao.UserRelationDAO;
import cz.proks.schoolpupilbook.shared.domain.UserRelation;
import cz.proks.schoolpupilbook.shared.restlet.RestMapping;

public class UserRelationServerResource extends BaseServerResource implements UserRelationResource {
	UserRelationDAO dao = new UserRelationDAO();
	
	@Override
	public UserRelation retrieve() {
		String studentParentId = (String) getRequestAttributes().get(RestMapping.PARAMETER_USER_RELATION_ID);
				
		if (studentParentId == null || studentParentId.isEmpty())
			return null;
			
		UserRelation userRelation = dao.find(studentParentId);
		return userRelation;		
	}

	@Override
	public void store(UserRelation obj) {				
		dao.save(obj);		
	}
}
